﻿using RPAVIEW.util;
using RPAVIEW.views.controlLibrary;
using SUNRPA.CONTROLS.IMPL.domain.flowItemParam;
using SUNRPA.CONTROLS.IMPL.util;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;

namespace RPAVIEW.views.EditPage.flows.UNZIPTargetN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        public Input() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            UNZIPTargetNParam param = ParamUtil.GetCurrentParam<UNZIPTargetNParam>();
            this.zipFilePath.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.createDir.GetBindingExpression(System.Windows.Controls.CheckBox.IsCheckedProperty).UpdateSource();
            this.unzipDir.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            param.UnzipPassword = this.unzippw.Password;
        }

        private void SelectFile(object sender, RoutedEventArgs e) {
            //选择文件
            string path = string.Empty;
            Microsoft.Win32.OpenFileDialog openFileDlg = FileUtil.OpenFileSelectDialog(".zip;.rar", "压缩文件(*.zip,*.rar)|*.zip;*.rar", path);
            // 调用ShowDialog方法显示对话框
            if(openFileDlg.ShowDialog() ?? false) { 
                path = openFileDlg.FileName;
                this.zipFilePath.Text = path;
            }
        }
        
        private void SelectDir(object sender, RoutedEventArgs e) {
            FolderBrowserDialog floder =  FileUtil.OpenFloderSelectDialog();
            DialogResult dr = floder.ShowDialog();
            if(DialogResult.OK.Equals(dr)) { 
                this.unzipDir.Text = floder.SelectedPath;
            }
        }
    }
}
